﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chowpoo.Sql;
using CourseSystem.Core.Entities;

namespace CourseSystem.Core.SqlServerDAL
{
    public class RadioChoicesDAL : CommonDal<RadioChoicesInfo>
    {
        public RadioChoicesDAL()
            : base(Settings.ConnectionName)
        {
        }

        public RadioChoicesDAL(string mConnectionStringName)
            : base(mConnectionStringName)
        {
        }

        public bool SetRadioKey(int rid, int keyId)
        {
            using (var dc = DataContext<RadioChoicesInfo>.CreateContext(ConnectionStringName))
            {
                return dc.ExecuteCommand("update radiochoices set isanswer=0 where rid={0} and id!={1}", rid, keyId) != 0;
            }
        }
    }
}
